package com.wngbms;

import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import lombok.extern.slf4j.Slf4j;

/**
 * serviceloader.load spi
 *
 */
@Slf4j
public class EventBusDemo {

    static EventBus bus = new EventBus();

    static {
        bus.register(new EventBusDemo());
    }

    public static void main(String[] args) {

        bus.post("send");

    }

    // 同一线程执行
    @Subscribe
    public void handle(String s) {
        log.info("recv: {}", s);
    }
}
